package com.vrv.app.cyberspace.modules.sys.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.vrv.app.cyberspace.common.utils.JSONResult;
import com.vrv.app.cyberspace.common.validator.Assert;
import com.vrv.app.cyberspace.common.validator.ValidatorUtils;
import com.vrv.app.cyberspace.modules.sys.entity.TodayBulletinTable;
import com.vrv.app.cyberspace.modules.sys.service.ITodayBulletinTableService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sm
 * @since 2017-12-15
 */
@Api(description="今日快报")
@RestController
@RequestMapping("/sys/todayBulletin")
public class TodayBulletinTableController extends BaseController {
    @Autowired
    private ITodayBulletinTableService todayBulletinTableService;

    @PostMapping()
    public JSONResult addTodayBulletin(TodayBulletinTable tb, String baseIDs, String advice) {
        ValidatorUtils.validateEntity(tb);
        Assert.isBlank(baseIDs, "baseIDs不能为空");
        return todayBulletinTableService.addTodayBulletin(tb, baseIDs, advice);
    }

    @PutMapping("/{id}")
    public JSONResult updateTodayBulletin(@PathVariable Integer id, TodayBulletinTable tb, String baseIDs) {
        return todayBulletinTableService.updateTodayBulletin(id, tb, baseIDs);
    }

    @GetMapping("/{id}")
    public JSONResult getTodayBulletin(@PathVariable Integer id) {
        return todayBulletinTableService.getTodayBulletin(id);
    }

    @GetMapping()
    public JSONResult getListTodayBulletin(Integer page, Integer size, Integer type, String startTime, String endTime, String title) {
        Assert.isNull(page, "page不能为空");
        Assert.isNull(size, "size不能为空");
        Assert.isNull(type, "type不能为空");
        return todayBulletinTableService.getListTodayBulletin(new Page<>(page, size), type, startTime, endTime, title);
    }
}

